const CommentService = require('../service/comment.service')

class commentController {
  // 1、发表评论
  async create(ctx, next) {
    const { id } = ctx.user
    const { content, momentId } = ctx.request.body

    console.log(content, momentId, id)
    const result = await CommentService.create(content, momentId, id)
    ctx.body = {
      code: 0,
      message: '发表评论成功',
      data: result,
    }
  }
  //   2、新增回复评论
  async reply(ctx, next) {
    const { id } = ctx.user
    const { content, momentId, commentId } = ctx.request.body
    console.log(content, momentId, commentId, id)
    const result = await CommentService.reply(content, momentId, commentId, id)
    ctx.body = {
      code: 0,
      message: '回复评论成功',
      data: result,
    }
  }
}

module.exports = new commentController()
